package oop3;

import oop3.pet.Cat;
import oop3.pet.Crocodile;

public class FinalTest {

	public static void main(String[] args) {
		// final:局部变量，运行期不能改
		final int i = 100;
		Person p = new Person();
		p.setName("xiaozhang");
		p.setAge(21);
		System.out.println(p);
		Person p2 = new Person("小五", 22, "女");
		System.out.println(p2);
	}

}

class YangziCrocodile extends Crocodile {

	public YangziCrocodile(String name, int health, int love, String type) {
		super(name, health, love, type);
	}

	@Override
	public void swim() {
		System.out.println(super.getName() + "在长江中游泳");
	}

	/*
	 * @Override public void cry() { System.out.println("小声的咕咕咕"); }
	 */
}
// error
// class BosiCat extends Cat {
//
// public BosiCat(String name, int health, int love, String type, String sex) {
// super(name, health, love, type, sex);
// // TODO Auto-generated constructor stub
// }
//
// }

// 定义属性，赋值一次
class Person {
	private String name;
	private int age;
	private final String sex;

	public Person() {
		sex = "男";
	}

	public Person(String name, int age, String sex) {
		super();
		this.name = name;
		this.age = age;
		this.sex = sex;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String getSex() {
		return sex;
	}

	@Override
	public String toString() {
		return "Person [name=" + name + ", age=" + age + ", sex=" + sex + "]";
	}

	// public void setSex(String s) {
	// this.sex = s;
	// }
}